package com.qingchunlin.springaop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
//@Component
@Order(2)
public class TestAspect3 {

    @Pointcut("com.qingchunlin.springaop.aspect.TestAspect2.pt()")
    public void pt() {}

    @Before("pt()")
    public void doBefore() {
        log.info("执行TestAspect3 Before...");
    }

    @After("pt()")
    public void doAfter() {
        log.info("执行TestAspect3 After...");
    }

    @AfterReturning("pt()")
    public void doAfterReturning() {
        log.info("执行TestAspect3 AfterReturning...");
    }

    @AfterThrowing("pt()")
    public void doAfterThrowing() {
        log.info("执行TestAspect3 AfterThrowing...");
    }

    @Around("pt()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("执行TestAspect3 Around 前...");
        Object result = proceedingJoinPoint.proceed();
        log.info("执行TestAspect3 Around 后...");
        return result;
    }
}